<template>
  <div class="main_box">

    <div class="add_wrap">
      <el-form label-width="200px">
        <div class="tit">
        <h2>医院医检信息</h2>
        <el-button
          plain
          size="small"
          type="success"
          icon="fa fa-mail-forward"
          @click="returnList"
        >
          返 回</el-button
        >
      </div>
        <el-row>
          <el-form-item label="医院:" v-if="reportData.hospitalName">
            <span>{{reportData.hospitalName}}</span>
          </el-form-item>
          <el-form-item label="医院科室:" v-if="reportData.officeName">
            <span>{{reportData.officeName}}</span>
          </el-form-item>
          <el-form-item label="医生:" v-if="reportData.doctorName">
            <span>{{reportData.doctorName}}</span>
          </el-form-item>
          <el-form-item label="医检机构:" v-if="reportData.institutionName">
            <span>{{reportData.institutionName}}</span>
          </el-form-item>
          <el-form-item label="医检科室:" v-if="reportData.insOfficeName">
            <span>{{reportData.insOfficeName}}</span>
          </el-form-item>
        </el-row>
         <div class="tit">
          <h2>基础信息</h2>
        </div>
        <el-row>
          <el-form-item label="编号:">
            <span>{{reportData.reportCode}}</span>
          </el-form-item>
          <el-form-item label="平台条码号:">
            <span>{{reportData.myReportCode}}</span>
          </el-form-item>
          <el-form-item label="医检条码号:">
            <span>{{reportData.insReportCode}}</span>
          </el-form-item>
          <el-form-item label="送检项目:">
            <span>{{reportData.itemName}}</span>
          </el-form-item>
          <!-- <el-form-item label="查询号:">
            <span>{{reportData.searchCode}}</span>
          </el-form-item> -->
          <el-form-item label="是否需要结果提醒:">
            <span>{{formatRemind(reportData.isRemind)}}</span>
          </el-form-item>
          <el-form-item label="当前收样员:">
            <span>{{reportData.syUserName}}({{reportData.syUserLevel}}级)</span>
          </el-form-item>
          <el-form-item label="所有收样员:">
            <span>{{reportData.syUserNames}}</span>
          </el-form-item>
          <el-form-item label="送检时间:">
            <span>{{reportData.reportBeginTime}}</span>
          </el-form-item>

          <el-form-item label="收取时间:">
            <span>{{reportData.reportCollectTime}}</span>
          </el-form-item>
          <el-form-item label="送达时间:">
            <span>{{reportData.reportDeliveredTime}}</span>
          </el-form-item>
          <el-form-item label="确认收到时间:">
            <span>{{reportData.reportReceivedTime}}</span>
          </el-form-item>

          <el-form-item label="已出报告时间:">
            <span>{{reportData.reportEndTime}}</span>
          </el-form-item>
          <el-form-item label="上传结果用户名:">
            <span>{{reportData.uploadUserName}}</span>
          </el-form-item>
          <el-form-item label="报告单状态:">
            <span>{{formatReportState(reportData.reportState)}}</span>
          </el-form-item>
          <el-form-item label="上机状态:">
            <span>{{formatTransmitState(reportData.transmitState)}}</span>
            <span v-if="reportData.transmitReason" style="color: red">{{reportData.transmitReason}}</span>
          </el-form-item>
          <el-form-item label="异常状态:">
            <span>{{formatAbnormalState(reportData.abnormalState)}}</span>
          </el-form-item>
          <el-form-item label="财务备注:">
            <span>{{reportData.financeRemark}}</span>
          </el-form-item>
          <el-form-item label="备注:">
            <span>{{reportData.remark}}</span>
          </el-form-item>
          <el-form-item label="创建人:">
            <span>{{ reportData.createUserName}}</span>
          </el-form-item>
          <el-form-item label="创建时间:">
            <span>{{ reportData.createDate }}</span>
          </el-form-item>
          <el-form-item label="修改人:">
            <span>{{ reportData.modifyUserName}}</span>
          </el-form-item>
          <el-form-item label="修改时间:">
            <span>{{ reportData.modifyDate }}</span>
          </el-form-item>
        </el-row>
        <div class="tit">
          <h2>患者信息</h2>
        </div>
        <el-row>
          <el-form-item label="患者姓名:">
            <span>{{reportData.patientName}}</span>
          </el-form-item>
          <el-form-item label="患者性别:">
             <span v-if="reportData.patientSex == 1">男</span>
            <span v-else-if="reportData.patientSex == 2">女</span>
          </el-form-item>
          <el-form-item label="患者身份证:">
            <span>{{reportData.patientCard}}</span>
          </el-form-item>
          <el-form-item label="证件类型:">
            <span v-if="reportData.cardType == 1">居民身份证</span>
            <span v-else-if="reportData.cardType == 9">其他</span>
          </el-form-item>
          <el-form-item label="患者出生日期">
            <span>{{reportData.birthday}}</span>
          </el-form-item>
          <el-form-item label="患者年龄:">
            <span v-if="reportData.patientAge">{{reportData.patientAge}}岁</span>
						<span v-if="reportData.patientMonth"> {{reportData.patientMonth}}月</span>
						<span v-if="reportData.patientDay"> {{reportData.patientDay}}天</span>
          </el-form-item>
          <el-form-item label="患者电话:">
            <span>{{reportData.patientPhone}}</span>
          </el-form-item>

          <el-form-item label="基本病情:">
            <span>{{reportData.patientInfo}}</span>
          </el-form-item>

        </el-row>
        <div class="tit">
          <h2>更多信息</h2>
        </div>
        <el-row>
            <RichEditor :htmlText="reportData.originInfo" :readOnly ="true"></RichEditor>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

<script>
import { FORMAT_DATE_YYYY_MM_DD } from "@/constants/constants";
import Map from "@/components/Map";
import ReportApi from "@/api/report/report";
import RichEditor from "@/components/RichEditor"
// import "viewerjs/dist/viewer.css";
// import Viewer from "v-viewer";
// import { mapGetters, mapActions } from 'vuex'
export default {
  data() {
    return {
      reportData: ""
    };
  },
  components: {
    Map,RichEditor
  },
  computed: {
  },
  beforeRouteLeave(to,from,next){
    to.meta.keepAlive = true
    next()
  },
  methods: {
    getData() {
      ReportApi.getReport({reportId: this.$route.query.id})
       .then(res => {
          this.reportData = res.data;
          if (res.data.syUserList && res.data.syUserList.length > 0){
            let syUserNames = ''
            res.data.syUserList.forEach((item,index)=>{
              syUserNames = syUserNames + item.userName + '(' + Number(index+1) + '级) ，'
            })
            this.reportData.syUserNames = syUserNames.substr(0,syUserNames.length-1)
          }
        });
    },
    formatDate(value) {
      return this.$Utils.formatDate(value, "yyyy-MM-dd");
    },
    formatRemind(value) {
      if(value == 0) {
        return "否"
      }else if(value == 1){
        return "是"
      }
    },
    formatPrintState (cellValue) {
      if (cellValue === 0) {
        return '未打印'
      } else if (cellValue === 1) {
        return '已打印'
      }
    },
    formatAbnormalState (cellValue) {
      if (cellValue === 1) {
        return '条码号异常'
      } else if (cellValue === 2) {
        return '姓名/身份证异常'
      }else if (cellValue === 3) {
        return '年龄/性别异常'
      }else if (cellValue === 4) {
        return '多条结果'
      // }else if (cellValue === 5) {
      //   return '结果未出'
      // }else if (cellValue === 6) {
      //   return '结果时间太久，需去对于的官网查看'
      }else if (cellValue === 7) {
        return '报告单结果未全出'
      }else if (cellValue === 8) {
        return '认证错误'
      }
    },
    formatReportState (cellValue) {
      if (cellValue === 0) {
        return '未收取'
      } else if (cellValue === 5) {
        return '已收取'
      } else if (cellValue === 10) {
        return '已送达'
      } else if (cellValue === 12) {
        return '已收到'
      } else if (cellValue === 15) {
        return '检测中'
      } else if (cellValue === 18) {
        return "取消中";
      } else if (cellValue === 19) {
        return "已取消";
      } else if (cellValue === 20) {
        return '已出结果'
      }
    },
    //报告单在医检处理状态（0.待接收 5.已接收 10.上机成功 14.上机失败 15.再次上机 20.已完成）
    formatTransmitState (state) {
      switch(state){
        case 0:
          return "待接收";
        case 4:
          return "接收失败";
        case 5:
          return "已接收";
        case 10:
          return "上机成功";
        case 14:
          return "上机失败";
        case 15:
          return "再次上机";
          case 19:
          return "已取消";
        case 20:
          return "已完成"
      }
    },
    formatSyUserLevel(index){
      let result = this.$Utils.numberToChinese(index);
      return result + '级'
    },
    returnList() {
      this.$store.dispatch('delView', this.$route);
      this.$router.push({ path:'/report/reportManagement'})
    }
  },
  mounted() {
    this.getData();
  }
};
</script>
<!-- <style lang="scss" src="@/assets/css/views/Detail.scss" scope> -->
<style lang="scss" src="@/assets/css/views/add.scss" scope></style>
</style>
